//package com.ycy.lucene.sort;
//
//import com.ycy.lucene.index.IndexReadDemo;
//import org.apache.lucene.index.LeafReaderContext;
//import org.apache.lucene.index.Term;
//import org.apache.lucene.queries.CustomScoreProvider;
//import org.apache.lucene.queries.CustomScoreQuery;
//import org.apache.lucene.queries.function.FunctionQuery;
//import org.apache.lucene.search.BooleanClause;
//import org.apache.lucene.search.BooleanQuery;
//import org.apache.lucene.search.Query;
//import org.apache.lucene.search.TermQuery;
//
//import java.io.IOException;
//
///**
// * 自定义评分
// * 对所有召回的文档打分
// */
//public class CustomScoreQueryDemo {
//  /**
//   * 自定义
//   */
//  public class CustomScoreQueryDemo1 extends CustomScoreQuery {
//
//    public CustomScoreQueryDemo1(Query subQuery) {
//      super(subQuery);
//    }
//
//    public CustomScoreQueryDemo1(Query subQuery, FunctionQuery scoringQuery) {
//      super(subQuery, scoringQuery);
//    }
//
//    public CustomScoreQueryDemo1(Query subQuery, FunctionQuery... scoringQueries) {
//      super(subQuery, scoringQueries);
//    }
//
//    @Override
//    protected CustomScoreProvider getCustomScoreProvider(LeafReaderContext context) throws IOException {
//      return new CustomScoreProviderDemo(context);
//    }
//
//    class CustomScoreProviderDemo extends CustomScoreProvider {
//
//      /**
//       * Creates a new instance of the provider class for the given {@link }.
//       *
//       * @param context
//       */
//      public CustomScoreProviderDemo(LeafReaderContext context) {
//        super(context);
//      }
//
//      @Override
//      public float customScore(int doc, float subQueryScore, float valSrcScore) throws IOException {
//        System.out.println(doc + " 评分:" + subQueryScore);
//        System.out.println(doc + " 评分:" + valSrcScore);
//        return super.customScore(doc, subQueryScore, valSrcScore);
//      }
//    }
//  }
//
//  /**
//   *
//   */
//  public void searchCustomQuery() {
//    BooleanQuery.Builder builder = new BooleanQuery.Builder();
//    builder.add(new TermQuery(new Term("name", "店")), BooleanClause.Occur.MUST);
//    builder.add(new TermQuery(new Term("name", "word")), BooleanClause.Occur.MUST_NOT);
//    BooleanQuery booleanQuery = builder.build();
//    CustomScoreQueryDemo1 customScoreQueryDemo = new CustomScoreQueryDemo1(booleanQuery);
//    IndexReadDemo.search(customScoreQueryDemo);
//  }
//
//
//}
